package cn.wnhyang.generator.service.impl;

import cn.wnhyang.generator.convert.AssemblyLogConvert;
import cn.wnhyang.generator.entity.AssemblyLog;
import cn.wnhyang.generator.mapper.AssemblyLogMapper;
import cn.wnhyang.generator.service.AssemblyLogService;
import cn.wnhyang.generator.vo.create.AssemblyLogCreateVO;
import cn.wnhyang.generator.vo.page.AssemblyLogPageVO;
import cn.wnhyang.generator.vo.update.AssemblyLogUpdateVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import cn.wnhyang.generator.pojo.PageResult;
import org.springframework.transaction.annotation.Transactional;

/**
 * 单柜装配日志 服务实现类
 *
 * @author cfl
 * @since 2024/11/26
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AssemblyLogServiceImpl implements AssemblyLogService {

    private final AssemblyLogMapper assemblyLogMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long create(AssemblyLogCreateVO createVO) {
        AssemblyLog assemblyLog = AssemblyLogConvert.INSTANCE.convert(createVO);
        assemblyLogMapper.insert(assemblyLog);
        return Long.valueOf(assemblyLog.getId());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(AssemblyLogUpdateVO updateVO) {
        AssemblyLog assemblyLog = AssemblyLogConvert.INSTANCE.convert(updateVO);
        assemblyLogMapper.updateById(assemblyLog);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(Long id) {
        assemblyLogMapper.deleteById(id);
    }

    @Override
    public AssemblyLog get(Long id) {
        return assemblyLogMapper.selectById(id);
    }

    @Override
    public PageResult<AssemblyLog> page(AssemblyLogPageVO pageVO) {
        return assemblyLogMapper.selectPage(pageVO);
    }

}
